import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
//引入路由
import router from './router'
//引入axios
import axios from 'axios'
// 引入公共js
import ggfunction from "../ggfun/ggFunction.js"
//全局引入element
import ElementUI from 'element-ui';  
//映入echarts
import * as echarts from 'echarts'         
 //全局引入element的样式
import 'element-ui/lib/theme-chalk/index.css';   
//解决跨域请求
axios.defaults.withCredentials = true; 

// 请求拦截器
axios.interceptors.request.use(
 config => {
//  token && (config.headers.Authorization = token)
    const token = sessionStorage.getItem('token'); 
    token && (config.headers.token = token) //在请求头中添加
 return config
 },
 error => {
 return Promise.error(error)
 })


Vue.prototype.HOME = '/api' 

Vue.use(VueRouter);
Vue.use(ggfunction);
Vue.use(ElementUI);
Vue.prototype.$axios = axios;
Vue.prototype.$echarts = echarts;
Vue.config.productionTip = false


new Vue({
  el: '#app',
  router,
  render: h => h(App)
}).$mount("#app")


